<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div id="app">
        <div v-for="(user,index) in userList" :key="index" style="display: flex;">
            <span>{{index}}:</span>
            <span>姓名:</span>
            <span>{{user.name}}</span>
            <span>年龄:</span>
            <span>{{user.age}}</span>
            <span>性别:</span>
            <span>{{user.sex | formatterSex}}</span>
            <span>评级:</span>
            <div>
                <div v-if="user.type==1">优秀</div>
                <div v-else-if="user.type==2">良好</div>
                <div v-else-if="user.type==3">一般</div>
                <div v-else>不及格</div>
            </div>
        </div>

    </div>
</body>
<script>
    new Vue({
        el: '#app',
        data: {
            userList: [{
                name: '张三',
                age: '18',
                type: 1,
                sex: 0
            }, {
                name: '莉丝',
                age: '20',
                type: 2,
                sex: 1
            }, {
                name: '王二',
                age: '22',
                type: 5,
                sex: 2
            }, ]
        },
        filters: {
            formatterSex(val) {
                if (val == 1) {
                    return '男'
                } else if (val == 0) {
                    return '女'
                } else {
                    return '未知'
                }
            }
        }
    });
</script>

</html>